package com.gp.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.gp.mapper.BaseAddressMapper;
import com.gp.model.entity.BaseAddress;
import com.gp.model.entity.BaseUser;
import com.gp.service.IBaseAddressService;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 弓成龙
 * @since 2017-12-19
 */
@Service
public class BaseAddressServiceImpl extends ServiceImpl<BaseAddressMapper, BaseAddress> implements IBaseAddressService {

	@Autowired
	private BaseAddressMapper addressMapper;

	@Override
	public List<BaseAddress> getAddressList(Long userId) {

		Map<String, Object> arg0 = new HashMap();
		arg0.put("user_id", userId);
		List<BaseAddress> list = addressMapper.selectByMap(arg0);
		return list;
	}

	@Override
	public BaseAddress getAddress(Long addressId) {
		return addressMapper.selectById(addressId);
	}

	@Override
	public int insertAddress(BaseAddress address) {
		return addressMapper.insertAddress(address);
	}

	@Override
	public void resetAddress(BaseUser baseUser) {
		addressMapper.resetAddress(baseUser.getId());
	}

}
